package info.motteke.qjdbc.column.variable;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * BITに対応します。
 *
 * @author YWak
 *
 */
public final class BooleanVariable extends Variable {

    private boolean value;

    private boolean set = false;

    public BooleanVariable(){

    }

    public BooleanVariable(boolean value){
        is(value);
    }

    public void is(boolean value){
        this.value = value;
        set = true;
    }

    @Override
    void putValue(PreparedStatement pstmt, int index) throws SQLException {
        if(!set){
            throw new IllegalStateException();
        }

        pstmt.setBoolean(index, value);
    }

}
